import functools


def retry(tries=3):
    def deco(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            e = None
            for i in range(tries):
                try:
                    res = func(*args, **kwargs)
                    break
                except Exception as exc:
                    e = exc
                    print("Retrying ")
                    pass
            else:
                return e
            return res

        return wrapper

    return deco
